package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.CallNumberDao;
import dao.impl.CallNumberDaoImpl;
import domain.CallNumber;
import domain.User;

import java.util.List;

public class CallNumberService {
    String valueAsString = null;
    private CallNumberDao contacts = new CallNumberDaoImpl();

    //用户每天主叫通话个数统计
    public String ToJson(User user) {
        String telephone = user.getTelephone();
        int year = user.getYear();
        int month = user.getMonth();
        List<CallNumber> list = contacts.SelectCallTimeByTelephoneAndDate(telephone,year,month);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }






}
